// pages/taskDetail/taskDetail.js
import config from '@/config/config'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrl: config.imgUrl,
    gridConfig: {
      column: 3,
      width: 190,
      height: 190,
    },

    originFiles: [],
    detail: "",

    imageSrcList: [
      { url: 'https://tdesign.gtimg.com/miniprogram/images/image1.jpeg', type: 'image' },
      { url: 'https://tdesign.gtimg.com/miniprogram/images/image1.jpeg', type: 'image' },
      { url: 'https://tdesign.gtimg.com/miniprogram/images/image1.jpeg', type: 'image' },
    ],

    showConfirm: false,
    imageOnTop: false
  },

  handleSuccess(e) {
    const { files } = e.detail;
    this.setData({
      originFiles: files,
    });
  },

  handleRemove(e) {
    const { index } = e.detail;
    const { originFiles } = this.data;
    originFiles.splice(index, 1);
    this.setData({
      originFiles,
    });
  },

  handleClick(e) {
    console.log(e.detail.file);
  },

  onDetailChange(e) {
    this.setData({
      detail: e.detail.value,
    });
  },

  // 图片预览
  showImg(e) {
    // console.log(e.currentTarget.dataset);
    let { img, index } = e.currentTarget.dataset
    console.log(img, index);
    wx.previewMedia({
      sources: img,
      current: index,
    });
  },

  submit() {
    // this.setData({ showConfirm: true })
    this.setData({ imageOnTop: true })
    
  },

  confirmDialog() {
    console.log('确定');
    this.setData({ showConfirm: false })
  },

  cancelDialog() {
    console.log('取消');
    this.setData({ showConfirm: false })
  },

  confirmDialog2() {
    this.setData({ imageOnTop: false })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})